﻿package ios.di.logviewer.data;

import java.util.Date;
/**
 * LogEntry过滤器，根据业务类型、供应商、时间等信息来过滤LogEntry。
 * @author LuoHouQi
 *
 */
public class LogEntryFilter {
	private String bussnessType;
	private String vendorID;
	private Date bunessDateStart,bunessDateEnd;
	private Date happenDateStart,happenDateEnd;
	
	public String getBussnessType() {
		return bussnessType;
	}
	public void setBussnessType(String bussnessType) {
		this.bussnessType = bussnessType;
	}
	public String getVendorID() {
		return vendorID;
	}
	public void setVendorID(String vendorID) {
		this.vendorID = vendorID;
	}
	public Date getBunessDateStart() {
		return bunessDateStart;
	}
	public void setBunessDateStart(Date bunessDateStart) {
		this.bunessDateStart = bunessDateStart;
	}
	public Date getBunessDateEnd() {
		return bunessDateEnd;
	}
	public void setBunessDateEnd(Date bunessDateEnd) {
		this.bunessDateEnd = bunessDateEnd;
	}
	public Date getHappenDateStart() {
		return happenDateStart;
	}
	public void setHappenDateStart(Date happenDateStart) {
		this.happenDateStart = happenDateStart;
	}
	public Date getHappenDateEnd() {
		return happenDateEnd;
	}
	public void setHappenDateend(Date happenDateend) {
		this.happenDateEnd = happenDateend;
	}
	
	public boolean match(LogEntry logEntry)
	{
		if(this.getBussnessType()!=null&&!this.getBussnessType().equals("全部")&& !this.getBussnessType().equals(""))
		{
			if (!this.getBussnessType().equals(logEntry.getBussnessType()))
				return false;
		}
		if(this.getVendorID()!=null && !this.getVendorID().equals("") && !this.getVendorID().equals(logEntry.getVendorID()))
		{
			if(!this.getVendorID().equals(logEntry.getVendorID()))
				return false;
		}
		if(this.getBunessDateStart()!= null)
		{
			if(this.getBunessDateStart().after(logEntry.getBussnessDate()))
				return false;
		}
		if(this.getBunessDateEnd()!= null)
		{
			if(this.getBunessDateEnd().before(logEntry.getBussnessDate()))
				return false;
		}
		if(this.getHappenDateStart()!=null)
			if(this.getHappenDateStart().after(logEntry.getHappenDate()))
				
				return false;
		if(this.getHappenDateEnd()!=null)
			if(this.getHappenDateEnd().before(logEntry.getHappenDate()))
				return false;
		
		return true;

	}
	
}
